import http from '@/utils/axios'

export default {
  //获得所属应用选项
  getAppTypeList() {
    return http({
      url: `/management-application/app/getDoMain`,
      method: 'get',
    })
  },

  //==权限组=============
  //查询权限组
  getPermisGroup(prams) {
    return http({
      url: `/management-authority/privilege_group/select`,
      method: 'get',
      params: prams,
    })
  },
  addPermisGroup(prams) {
    return http({
      url: `/management-authority/privilege_group/add`,
      method: 'post',
      data: prams,
    })
  },
  delPermisGroup(prams) {
    return http({
      url: `/management-authority/privilege_group/remove`,
      method: 'post',
      data: prams,
    })
  },
  upPermisGroup(prams) {
    return http({
      url: `/management-authority/privilege_group/edit`,
      method: 'post',
      data: prams,
    })
  },
  //===关联角色====================================================
  //已绑定角色
  getGroupRelRole(prams) {
    return http({
      url: `/management-authority/privilege_group/roles/bound`,
      method: 'get',
      params: prams,
    })
  },
  //树
  searchTree(name, privilege) {
    return http({
      url: `/management-authority/role/roles/tree?privilege=${privilege}&searchName=${name}`,
      method: 'get',
    })
  },
  //非托管列表
  getTableData(prams) {
    let ur = ''
    if (prams.search) {
      ur += '&search=' + prams.search
    }
    return http({
      url: `/management-authority/role/roles/page/get?pageNo=${prams.pageNo}&pageSize=${prams.pageSize}&parent=-2` + ur,
      method: 'get',
    })
  },
  //添加角色至组
  addRoleToGroup(prams) {
    return http({
      url: `/management-authority/privilege_group/roles/bind`,
      method: 'post',
      data: prams,
    })
  },
  //从组中移除角色
  delRoleToGroup(prams) {
    return http({
      url: `/management-authority/privilege_group/roles/unbind`,
      method: 'post',
      data: prams,
    })
  },
  //权限绑定角色
  addRoleToPerm(prams) {
    return http({
      url: `/management-authority/privileges/roles/bind`,
      method: 'post',
      data: prams,
    })
  },
  //权限删除角色
  delRoleToPerm(prams) {
    return http({
      url: `/management-authority/privileges/roles/unbind`,
      method: 'post',
      data: prams,
    })
  },

  //==权限列表==================================
  //查询权限组对应的列表
  getPermisList(prams) {
    return http({
      url: `/management-authority/privileges/select_page`,
      method: 'get',
      params: prams,
    })
  },
  //新增权限
  addPermis(prams) {
    return http({
      url: `/management-authority/privileges/add`,
      method: 'post',
      data: prams,
    })
  },
  //修改权限
  updatePermis(prams) {
    return http({
      url: `/management-authority/privileges/edit`,
      method: 'post',
      data: prams,
    })
  },
  //
  getPermisDetial(prams) {
    return http({
      url: `/management-authority/privileges/select_detail`,
      method: 'get',
      params: prams,
    })
  },
  //删除权限
  deletePermis(prams) {
    return http({
      url: `/management-authority/privileges/remove`,
      method: 'post',
      data: prams,
    })
  },

  //==资源==================================
  //查询分页资源
  getResources(prams) {
    return http({
      url: `/management-authority/resources/select_page`,
      method: 'get',
      params: prams,
    })
  },
  //资源对应角色
  getRoleToResources(prams) {
    return http({
      url: `/management-authority/role/select_by_resource`,
      method: 'get',
      params: prams,
    })
  },
  //查询资源对应权限
  getPermToResources(prams) {
    return http({
      url: `/management-authority/privileges/select_by_resource`,
      method: 'get',
      params: prams,
    })
  },
  //根据表达式匹配资源
  getResourcesForExp(prams) {
    return http({
      url: `/management-authority/resources/select_by_action`,
      method: 'get',
      params: prams,
    })
  },
}
